home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / STANDALO / BOUNCE_C / LINEBOX.H < prev   
Text File  |  1991-01-24  |  1KB  |  36 lines

  1. /*
  2.  * LineBox.h    -- this file describes the LineBox class, which implements a
  3.  * 'bouncing' line object.  It's initialized with the number of lines to draw and
  4.  * a box in the local grafport to draw it in.  The actual bouncing line code is 
  5.  * adapted from "Macintosh Programming Primer" by Dave Mark and Cartwright Reed.
  6.  */
  7. #ifndef _LineBox_
  8. #define _LineBox_
  9.  
  10. #include <MacTypes.h>
  11.  
  12. struct LineBox : indirect {
  13.  
  14.     Rect        *lines;                    /* array of lines to draw */
  15.     int            numlines;                /* number of lines in array */
  16.     int            dtop, dbottom, dleft, dright;    /* delta rectangle */
  17.     int            top, bottom, left, right;        /* bounding box (local) */
  18.     GrafPtr        port;                    /* GrafPort to draw into */
  19.  
  20.     /* 'Public' methods */
  21.  
  22.     Boolean        Init(int, Rect *, GrafPtr);    /* returns false if init failed */
  23.     void        Draw(void);                /* redraws the entire box */
  24.     void        Idle(void);                /* advances the line by one & draws it */
  25.     void        Close(void);            /* deallocates the line array */
  26.  
  27.     /* 'Private' methods */
  28.  
  29.     void        DrawLine(int);            /* draws line number i */
  30.     void        RandomRect(Rect *);        /* randomizes the rectangle passed */
  31.     void        RecalcLine(int);        /* bumps line forward once */
  32. };
  33.  
  34. /* size of 'border' region for line box */
  35. #define    BORDER    1
  36. #endif    /* _LineBox_ */